﻿using System.Web.Mvc;
using Dexter.Logger.Contracts;
using Dexter.Plugins.Linkflood.Models;
using Dexter.Services;
using Dexter.Web.Mvc.Controllers.Plugin;
using Dexter.Web.Mvc.ViewModel.Backoffice.ViewsData.SettingsController;
using Dexter.Web.Utils;

namespace Dexter.Plugins.Linkflood.Controllers
{
	public class SettingController : PluginBackofficeControllerBase
	{
		public SettingController(IConfigurationService configurationService, IWebUtils webUtils, ILogger logger, IUrlBuilder urlBuilder, IContactService contactService, IPluginService pluginService) : base(configurationService, webUtils, logger, urlBuilder, contactService, pluginService)
		{
		}

		[AcceptVerbs(HttpVerbs.Get)]
		public ActionResult Index()
		{
			var data = base.GetViewData(new PluginViewData<LinkfloodBinder>(base.WebUtils, base.Configuration, base.UrlBuilder));

			return View(data);
		}

		[AcceptVerbs(HttpVerbs.Post)]
		public ActionResult Index(LinkfloodBinder binder)
		{
			if (!ModelState.IsValid)
			{
				var data = base.GetViewData(new PluginViewData<LinkfloodBinder>(base.WebUtils, base.Configuration, base.UrlBuilder));

				return View(data);
			}

			return RedirectToPluginList();
		}
	}
}